require 'config/environment'

task :check_parameters => [:check_complexity]

task :check_complexity do
  require 'lib/sentence_complexity/Function'
  @complexity_checker = Function.new
  @complexity_checker.crawl("lib/sentence_complexity/bunkei.seed")
  (Example.count / 100 + 1).times do |i|
    Example.find(:all,:select => "id,text,complexity",:order => "id ASC",:limit => 100,:offset => i*100).each do |example|
      complexity = (@complexity_checker.run(example.text).to_f + 1.0) / 5.0
      next if example.complexity == complexity
      example.update_attribute :complexity,complexity
    end
  end
end
